home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 26.zip
/
BS1 part 26
/
The Director Toolkit v1.0.adf
/
Programs
/
MIDImod
/
mididemo
< prev
next >
Wrap
Text File
|
1987-02-25
|
3KB
|
112 lines
rem midi sound module test example
rem When you run, wait until all disk activity stops, then
rem it should respond to MIDI note commands on channel 1
rem first, we create an array big enough to hold a note period table
rem and note number to sample-buffer table
rem make sure we can find the midi module
execute a,"assign mod: toolkit:options"
array 200,2
rem now setup the pics
rem create pics 1-4 by blitting from loaded pic in 5
setblack 1
load 5,"flash5.pic"
new 1,5
display 1
blit 5,29,14,29,14,153,105
new 2,5
display 2
blit 5,198,0,158,20,153,133
new 3,5
display 3
blit 5,49,120,49,100,157,119
new 4,5
display 4
blit 5,209,134,169,94,142,105
rem don't need original pic anymore
free 5
rem loadup the sound samples
module "midi"
sound perioda,"load",1,0,"ToolKit:sounds/hammer1.snd"
sound periodb,"load",2,0,"ToolKit:sounds/switch.snd"
sound periodc,"load",3,0,"ToolKit:sounds/mtcymb.snd"
sound periodd,"load",4,0,"ToolKit:sounds/snare.snd"
rem setup midi
sound a,"midi",1,1
position -1,-1:rem adjust for overscan
rem setup a default period in the notetable
for i=0 to 99:@(i) = perioda:@(i+100)=1:next
rem build table of note sample-periods in the array from 0-99
i = 42:rem starting location for this octave
@(i) = 508
i=i+1:@(i) = 480
i=i+1:@(i) = 453
i=i+1:@(i) = 428
i=i+1:@(i) = 404
i=i+1:@(i) = 381
i=i+1:@(i) = 360
i=i+1:@(i) = 339
i=i+1:@(i) = 320
i=i+1:@(i) = 302
i=i+1:@(i) = 285
i=i+1:@(i) = 269
i=i+1
rem generate upper two octaves
for i=i to i+24
@(i)=@(i-12)/2
next
rem generate lower octaves
for i=41 to 0
@(i)=@(i+12)*2
next
rem fill the note table with sound buffer numbers
for i=100 to 199
@(i)=1+i%4
next
rem now trigger on midi notes
10 sound note,"wait"
velo = note/512:rem convert to 0-63 volume from 0-128 velocity info
note = note%256
if velo :rem a note on
rem play sample and display image selected by @(100+note)
rem with sample period selected by @(note)
b = @(100+note)
sound a,"play",b,1,velo-1,@(note)
display b
rem randomly colorize the image
for i=1 to 3
color -1,1,i,1+?15,1+?15,1+?15
next
setblack 0
goto 10
else :rem a note off
setblack 1
goto 10
endif